// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.IndexManagement;

public sealed partial class ModifyDataStreamRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>Performs one or more data stream modification actions in a single atomic operation.</para>
/// </summary>
public sealed partial class ModifyDataStreamRequest : PlainRequest<ModifyDataStreamRequestParameters>
{
	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementModifyDataStream;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "indices.modify_data_stream";

	/// <summary>
	/// <para>Actions to perform.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("actions")]
	public ICollection<Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamAction> Actions { get; set; }
}

/// <summary>
/// <para>Performs one or more data stream modification actions in a single atomic operation.</para>
/// </summary>
public sealed partial class ModifyDataStreamRequestDescriptor : RequestDescriptor<ModifyDataStreamRequestDescriptor, ModifyDataStreamRequestParameters>
{
	internal ModifyDataStreamRequestDescriptor(Action<ModifyDataStreamRequestDescriptor> configure) => configure.Invoke(this);

	public ModifyDataStreamRequestDescriptor()
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementModifyDataStream;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "indices.modify_data_stream";

	private ICollection<Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamAction> ActionsValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamActionDescriptor ActionsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamActionDescriptor> ActionsDescriptorAction { get; set; }
	private Action<Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamActionDescriptor>[] ActionsDescriptorActions { get; set; }

	/// <summary>
	/// <para>Actions to perform.</para>
	/// </summary>
	public ModifyDataStreamRequestDescriptor Actions(ICollection<Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamAction> actions)
	{
		ActionsDescriptor = null;
		ActionsDescriptorAction = null;
		ActionsDescriptorActions = null;
		ActionsValue = actions;
		return Self;
	}

	public ModifyDataStreamRequestDescriptor Actions(Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamActionDescriptor descriptor)
	{
		ActionsValue = null;
		ActionsDescriptorAction = null;
		ActionsDescriptorActions = null;
		ActionsDescriptor = descriptor;
		return Self;
	}

	public ModifyDataStreamRequestDescriptor Actions(Action<Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamActionDescriptor> configure)
	{
		ActionsValue = null;
		ActionsDescriptor = null;
		ActionsDescriptorActions = null;
		ActionsDescriptorAction = configure;
		return Self;
	}

	public ModifyDataStreamRequestDescriptor Actions(params Action<Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamActionDescriptor>[] configure)
	{
		ActionsValue = null;
		ActionsDescriptor = null;
		ActionsDescriptorAction = null;
		ActionsDescriptorActions = configure;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (ActionsDescriptor is not null)
		{
			writer.WritePropertyName("actions");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, ActionsDescriptor, options);
			writer.WriteEndArray();
		}
		else if (ActionsDescriptorAction is not null)
		{
			writer.WritePropertyName("actions");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamActionDescriptor(ActionsDescriptorAction), options);
			writer.WriteEndArray();
		}
		else if (ActionsDescriptorActions is not null)
		{
			writer.WritePropertyName("actions");
			writer.WriteStartArray();
			foreach (var action in ActionsDescriptorActions)
			{
				JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.IndexManagement.IndexModifyDataStreamActionDescriptor(action), options);
			}

			writer.WriteEndArray();
		}
		else
		{
			writer.WritePropertyName("actions");
			JsonSerializer.Serialize(writer, ActionsValue, options);
		}

		writer.WriteEndObject();
	}
}